
#include <string.h>
#include <stdio.h>
#include"mhscpu.h"

void UART_Configuration(void);

int main(void)
{
	uint8_t tmp;
	
	SYSCTRL_APBPeriphClockCmd(SYSCTRL_APBPeriph_UART0 | SYSCTRL_APBPeriph_UART1 | SYSCTRL_APBPeriph_GPIO,ENABLE);
	SYSCTRL_APBPeriphResetCmd(SYSCTRL_APBPeriph_UART0 | SYSCTRL_APBPeriph_UART1 , ENABLE);
	
	UART_Configuration();
	
	printf("MegaHunt SCPU Reset V1.0.\n");

	while(1) {
// 		if(UART_GetLineStatus(UART1) & UART_LINE_STATUS_RX_RECVD)
// 		{
// 			tmp = UART_ReceiveData(UART1);
// 			UART_SendData(UART1, tmp);
// 		}
		printf("%08X", 0x0);
	}
}

void UART_Configuration(void)
{
	UART_InitTypeDef UART_InitStructure;

	GPIO_PinRemapConfig(GPIOA, GPIO_Pin_0 | GPIO_Pin_1, GPIO_Remap_0);
	
	UART_InitStructure.UART_BaudRate = 115200;
	UART_InitStructure.UART_WordLength = UART_WordLength_8b;
	UART_InitStructure.UART_StopBits = UART_StopBits_1;
	UART_InitStructure.UART_Parity = UART_Parity_No;

	UART_Init(UART0, &UART_InitStructure);	
	UART_Init(UART1, &UART_InitStructure);	
}


int fputc(int ch, FILE *f)
{
  /* Place your implementation of fputc here */
  /* e.g. write a character to the USART */
  while(!UART_IsTXEmpty(UART0));
	UART_SendData(UART0, (uint8_t) ch);
  return ch;
}


#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{ 
	/* User can add his own implementation to report the file name and line number,
	 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

	/* Infinite loop */
	while (1)
	{
	}
}
#endif






